package com.heima.wemedia.feign;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.dtos.WmSensitiveDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.model.wemedia.pojos.WmSensitive;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmSensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1")
public class WemediaClient {
    @Autowired
    private WmSensitiveService sensitiveService;

    @Autowired
    private WmChannelService wmchannelService;

    /**
     *  查询敏感词列表
     */
    @PostMapping("/sensitive/list")
    public ResponseResult list(@RequestBody WmSensitiveDto dto){
        return sensitiveService.findAll(dto);
    }

    /**
     * 新增敏感词
     */
    @PostMapping("/sensitive/save")
    public ResponseResult save(@RequestBody WmSensitive wmSensitive){
        return sensitiveService.addSensitive(wmSensitive);
    }

    /**
     * 删除敏感词
     */
    @DeleteMapping("/sensitive/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return sensitiveService.deleteSensitive(id);
    }

    /**
     * 修改敏感词
     */
    @PostMapping("/sensitive/update")
    public ResponseResult updateSensitive(@RequestBody WmSensitive wmSensitive){
        return sensitiveService.updateSensitive(wmSensitive);
    }

    /**
     * 频道列表
     * @param dto
     * @return
     */
    @PostMapping("/channel/list")
    public ResponseResult findAll(@RequestBody ChannelDto dto){
        return wmchannelService.findAll(dto);
    }

    /**
     * 添加频道
     */
    @PostMapping("/channel/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel){
        return wmchannelService.addWmChannel(wmChannel);
    }

    /**
     * 删除频道
     */
    @GetMapping("/channel/del/{id}")
    public ResponseResult deleteChannel(@PathVariable Integer id){
        return wmchannelService.delete(id);
    }

    /**
     * 修改频道
     */
    @PostMapping("/channel/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel){
        return wmchannelService.update(wmChannel);
    }



}
